package igor.mass.model;

import java.util.Vector;

public class AndroidSmarthouse {
	public Vector<AndroidRoom> rooms = new Vector<AndroidRoom>();
	
	public String toString(){
		StringBuilder sb = new StringBuilder();
		for(AndroidRoom room: rooms){
			sb.append(room.name+"\n");
			for (AndroidDevice device : room.devices) {
				sb.append("\t"+device.name+"\n");
				for (AndroidCommand command : device.commands) {
					sb.append("\t\t"+command.name+"\n");
					sb.append("\t\t\t");
					for (AndroidParam param : command.params) {
						sb.append(param.name+" ");
					}
					sb.append("\n");
				}
			}
		}
		return sb.toString();
	}
	
	public static String XML(){
		StringBuilder sb = new StringBuilder();
		
		String s =
		
		"<smarthouse>\n"+
		"<room name=\"Living room\">\n"+
		"	<device name=\"Heater\" description=\"Device for heating the room\">\n"+
		"		<command id=\"0\" name=\"Toggle heater\" description=\"Turns the heater on or off\">\n"+
		"			<param name=\"State\" description=\"Sets the state of the heater\" id=\"0\" type=\"boolean\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"		<command id=\"1\" name=\"Set temperature\" description=\"Sets the temperature to specific value\">\n"+
		"			<param name=\"max\" description=\"The temperature which will never be exceeded\" id=\"1\" type=\"int\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"desired\" description=\"Desired temperature\" id=\"2\" type=\"int\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"economic\" description=\"In economic mode, heater will only be activated during off peak hours or when temperature gets too low\" id=\"3\" type=\"boolean\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"	</device>\n";
		sb.append(s);
		s=
		"	<device name=\"Light\" description=\"Manage light in the room\">\n"+
		"		<command id=\"0\" name=\"Set light\" description=\"Sets the light in the room to specified level and colour\">\n"+
		"			<param name=\"light\" description=\"Overall light level\" id=\"0\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"red\" description=\"Red light level\" id=\"1\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"green\" description=\"Green light level\" id=\"2\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"blue\" description=\"Blue light level\" id=\"3\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"	</device>\n";
		sb.append(s);
		s=		
		"	<device name=\"Light\" description=\"Manage light in the room\">\n"+
		"		<command id=\"0\" name=\"Set light\" description=\"Sets the light in the room to specified level and colour\">\n"+
		"			<param name=\"light\" description=\"Overall light level\" id=\"0\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"red\" description=\"Red light level\" id=\"1\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"green\" description=\"Green light level\" id=\"2\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"blue\" description=\"Blue light level\" id=\"3\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"	</device>\n"+
		"</room>\n";
		sb.append(s);
		s=
		"<room name=\"Bedroom\">\n"+
		"	<device name=\"Heater\" description=\"Device for heating the room\">\n"+
		"		<command id=\"0\" name=\"Toggle heater\" description=\"Turns the heater on or off\">\n"+
		"			<param name=\"State\" description=\"Sets the state of the heater\" id=\"0\" type=\"boolean\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"		<command id=\"1\" name=\"Set temperature\" description=\"Sets the temperature to specific value\">\n"+
		"			<param name=\"max\" description=\"The temperature which will never be exceeded\" id=\"1\" type=\"int\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"desired\" description=\"Desired temperature\" id=\"2\" type=\"int\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"economic\" description=\"In economic mode, heater will only be activated during off peak hours or when temperature gets too low\" id=\"3\" type=\"boolean\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"	</device>\n";
		sb.append(s);
		s=
		"	<device name=\"Light\" description=\"Manage light in the room\">\n"+
		"		<command id=\"0\" name=\"Set light\" description=\"Sets the light in the room to specified level and colour\">\n"+
		"			<param name=\"light\" description=\"Overall light level\" id=\"0\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"red\" description=\"Red light level\" id=\"1\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"green\" description=\"Green light level\" id=\"2\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"blue\" description=\"Blue light level\" id=\"3\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"	</device>\n"+
		"</room>\n";
		sb.append(s);
		s=
		"<room name=\"Kitchen\">\n"+
		"	<device name=\"Heater\" description=\"Device for heating the room\">\n"+
		"		<command id=\"0\" name=\"Toggle heater\" description=\"Turns the heater on or off\">\n"+
		"			<param name=\"State\" description=\"Sets the state of the heater\" id=\"0\" type=\"boolean\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"		<command id=\"1\" name=\"Set temperature\" description=\"Sets the temperature to specific value\">\n"+
		"			<param name=\"max\" description=\"The temperature which will never be exceeded\" id=\"1\" type=\"int\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"desired\" description=\"Desired temperature\" id=\"2\" type=\"int\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>true</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"economic\" description=\"In economic mode, heater will only be activated during off peak hours or when temperature gets too low\" id=\"3\" type=\"boolean\">\n"+
		"				<length>-1</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>false</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"	</device>\n";
		sb.append(s);
		s=
		"	<device name=\"Light\" description=\"Manage light in the room\">\n"+
		"		<command id=\"0\" name=\"Set light\" description=\"Sets the light in the room to specified level and colour\">\n"+
		"			<param name=\"light\" description=\"Overall light level\" id=\"0\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"red\" description=\"Red light level\" id=\"1\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"green\" description=\"Green light level\" id=\"2\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"			<param name=\"blue\" description=\"Blue light level\" id=\"3\" type=\"int\">\n"+
		"				<length>3</length>\n"+
		"				<mandatory>false</mandatory>\n"+
		"				<percentage>true</percentage>\n"+
		"			</param>\n"+
		"		</command>\n"+
		"	</device>\n"+
		"</room>\n"+
	"</smarthouse>\n";
		
		sb.append(s);
		return sb.toString();
	}

}
